package com.sj.entity;

import com.baomidou.mybatisplus.annotation.*;

import java.io.Serializable;
import java.time.LocalDateTime;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

/**
 * <p>
 * 角色菜单关联表
 * </p>
 *
 * @author 孙峻
 * @since 2022-03-09
 */
@Getter
@Setter
@Accessors(chain = true)
@TableName("sys_role_menu")
@ApiModel(value = "SysRoleMenu对象", description = "角色菜单关联表")
public class SysRoleMenu implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty("关联表id 自增长")
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    @ApiModelProperty("角色id")
    private Integer roleId;

    @ApiModelProperty("菜单id")
    private Integer menuId;

    @ApiModelProperty("是否删除 1 删除 0 未删除")
    @TableLogic
    private Boolean del;

    @ApiModelProperty("创建时间")
    @TableField(fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    private LocalDateTime createTime;

    public static SysRoleMenuBuilder builder() {
        return new SysRoleMenuBuilder();
    }

    public static final class SysRoleMenuBuilder {
        private Integer id;
        private Integer roleId;
        private Integer menuId;
        private Boolean del;
        private LocalDateTime createTime;

        private SysRoleMenuBuilder() {
        }

        public SysRoleMenuBuilder id(Integer id) {
            this.id = id;
            return this;
        }

        public SysRoleMenuBuilder roleId(Integer roleId) {
            this.roleId = roleId;
            return this;
        }

        public SysRoleMenuBuilder menuId(Integer menuId) {
            this.menuId = menuId;
            return this;
        }

        public SysRoleMenuBuilder del(Boolean del) {
            this.del = del;
            return this;
        }

        public SysRoleMenuBuilder createTime(LocalDateTime createTime) {
            this.createTime = createTime;
            return this;
        }

        public SysRoleMenu build() {
            SysRoleMenu sysRoleMenu = new SysRoleMenu();
            sysRoleMenu.setId(id);
            sysRoleMenu.setRoleId(roleId);
            sysRoleMenu.setMenuId(menuId);
            sysRoleMenu.setDel(del);
            sysRoleMenu.setCreateTime(createTime);
            return sysRoleMenu;
        }
    }
}
